package com.wedata.中台服务;

import cn.hutool.crypto.digest.MD5;
import cn.hutool.json.JSONArray;
import cn.hutool.json.JSONObject;
import com.wedata.HttpUtils;

import java.util.*;

public class OpenApi {

    public static void main(String[] args) {
        queryCoachSalaryList();
    }
    private static JSONObject 修改手机号(){
        JSONArray body = new JSONArray();
        String str = "1020009372873112237,15306002674;1087971731926421271,13107329357;1088006003663389271,15874815235;1088026544122901854,13657350041;1088040244224342290,18094379821;1088093488088988199,19913412658";
        String[] strs = str.split(";");
        for (String str1 : strs) {
            String[] str2 = str1.split(",");
            JSONObject obj = new JSONObject();
            obj.set("orderId", str2[0]);
            obj.set("phone", str2[1]);
            body.add(obj);
        }
        System.out.println(body);

        String sign = MD5.create().digestHex(body +"#5601291336c76762f1d56ce5b45b2419");
        JSONObject header = new JSONObject();
        header.set("X-SIGN",sign);
        header.set("X-TRACEID", UUID.randomUUID());
        header.set("X-APPKEY", "10067615200");
        JSONObject result = HttpUtils.sendPost("https://wedata.gymcity.com.cn/openapi/dc/douyin/laike/updateOrderPhone", header, body);
        //JSONObject result = HttpUtils.sendPost("http://localhost:9090/openapi/dc/douyin/laike/updateOrderPhone", header, body);
        return result;
    }
    private static JSONObject 查到抖音空手机号的订单(){
        JSONObject body = new JSONObject();
        body.set("startTime", "2025-08-21 00:00:00");
        body.set("endTime", "2025-08-21 23:59:59");
        String sign = MD5.create().digestHex(body +"#205dda3a73b49cb6675260e43c1a39e9");
        JSONObject header = new JSONObject();
        header.set("X-SIGN",sign);
        header.set("X-TRACEID", UUID.randomUUID());
        header.set("X-APPKEY", "55753479369");
        JSONObject result = HttpUtils.sendPost("https://wedata.gymcity.com.cn/openapi/dc/douyin/laike/queryEmptyPhoneOrderList", header, body);
        return result;
    }

    private static JSONObject 查抖音适应门店(){
        JSONObject body = new JSONObject();
        body.set("order_id", "1087160503004824318");
        String sign = MD5.create().digestHex(body +"#5601291336c76762f1d56ce5b45b2419");
        JSONObject header = new JSONObject();
        header.set("X-SIGN",sign);
        header.set("X-TRACEID", UUID.randomUUID());
        header.set("X-APPKEY", "10067615200");
        JSONObject result = HttpUtils.sendPost("https://wedata.gymcity.com.cn/openapi/dc/douyin/laike/queryOrder", header, body);
        return result;
    }

    /**
     * 查询销售目标
     * @return
     */
    private static JSONObject test_querytarget(){
        JSONObject body = new JSONObject();
        body.set("targetType", 6);
        body.set("month", 202503);

        String sign = MD5.create().digestHex(body +"#5601291336c76762f1d56ce5b45b2419");
        JSONObject header = new JSONObject();
        header.set("X-SIGN",sign);
        header.set("X-TRACEID", UUID.randomUUID());
        header.set("X-APPKEY", "10067615200");
        JSONObject result = HttpUtils.sendPost("https://twedata.gymcity.com.cn/openapi/finance/performance/target/query", header, body);
        return result;
    }


    /**
     * 查询企业微信token
     * @return
     */
    private static JSONObject test_getWeiXinStableToken(){
        JSONObject body = new JSONObject();
        body.set("corpid", "wwbb3eaebf35674eef");
        body.set("agentId", 1000042);

        String sign = MD5.create().digestHex(body +"#5601291336c76762f1d56ce5b45b2419");
        JSONObject header = new JSONObject();
        header.set("X-SIGN",sign);
        header.set("X-TRACEID", UUID.randomUUID());
        header.set("X-APPKEY", "10067615200");
        JSONObject result = HttpUtils.sendPost("https://twedata.gymcity.com.cn/openapi/third/getWeiXinStableToken", header, body);
        return result;
    }

    /**
     * 查询企业微信token
     * @return
     */
    private static JSONObject test_getQiYeWeiXinToken(){
        JSONObject body = new JSONObject();
        body.set("corpid", "wwbb3eaebf35674eef");
        body.set("agentId", 1000042);

        String sign = MD5.create().digestHex(body +"#5601291336c76762f1d56ce5b45b2419");
        JSONObject header = new JSONObject();
        header.set("X-SIGN",sign);
        header.set("X-TRACEID", UUID.randomUUID());
        header.set("X-APPKEY", "10067615200");
        JSONObject result = HttpUtils.sendPost("https://twedata.gymcity.com.cn/openapi/third/getQiYeWeiXinToken", header, body);
        return result;
    }
    /**
     * 查询企业微信token
     * @return
     */
    private static JSONObject pro_getQiYeWeiXinToken(){
        JSONObject body = new JSONObject();
        body.set("corpid", "wwbb3eaebf35674eef");
        body.set("agentId", 1000005);

        String sign = MD5.create().digestHex(body +"#5601291336c76762f1d56ce5b45b2419");
        JSONObject header = new JSONObject();
        header.set("X-SIGN",sign);
        header.set("X-TRACEID", UUID.randomUUID());
        header.set("X-APPKEY", "10067615200");
        JSONObject result = HttpUtils.sendPost("https://wedata.gymcity.com.cn/openapi/third/getQiYeWeiXinToken", header, body);
        return result;
    }

    /**
     * 查询教练工资列表
     * @return
     */
    private static JSONObject queryCoachSalaryList(){
        JSONObject body = new JSONObject();
        body.set("coachId", 15665);
        body.set("salarySummaryId", 433006);
        //sendRequest result:{"code":200,"msg":"操作成功","data":{"reality":15320.73,"baseSalary8":5768.85,"assess15":9551.88,"basePayableSalary":5768.85,"baseSalaryAlgo":"计算=综合底薪(6500.00)*实际出勤天数(11.50)/应出勤天数(26.00)+综合底薪(6000.00)*实际出勤天数(12.00)/应出勤天数(26.00)+综合底薪(2400.00)*实际出勤天数(2.00)/应出勤天数(26.00)+病假工资(0.00)-考勤扣款(60.00)","totalCourseFee":4380.00,"totalCommissionItem":{"amount":941.01,"subItemVoList":[{"subItemName":"转换奖励","amount":600.00}]},"totalPerformance":0.00,"coachSubsidyItem":{"amount":6481.07,"subItemVoList":[{"subItemName":"按照店长职级计算工资","amount":6481.07}]},"coachRewardPunishmentItem":{"amount":-200.00,"subItemVoList":[{"subItemName":"顾客【杨贺然】总结少一次","amount":-50.0},{"subItemName":"何栋鑫-张应秋子会员-PQ选项未勾选","amount":-50.0},{"subItemName":"第二次复查：何栋鑫-张应秋子会员-PQ选项未勾选","amount":-50.0},{"subItemName":"顾客【周建华】反馈任务过期，第一次课总结未发规划纸","amount":-50.0}]},"payable":17370.93,"socialSecurityHousingFund":-636.30,"personalIncomeTax":-1413.90},"time":1736306251}
        //sendRequest result:{"code":200,"msg":"操作成功","data":{"reality":15320.73,"baseSalary8":5768.85,"assess15":9551.88,"basePayableSalary":5768.85,"baseSalaryAlgo":"计算=综合底薪(6500.00)*实际出勤天数(11.50)/应出勤天数(26.00)+综合底薪(6000.00)*实际出勤天数(12.00)/应出勤天数(26.00)+综合底薪(2400.00)*实际出勤天数(2.00)/应出勤天数(26.00)+病假工资(0.00)-考勤扣款(60.00)","totalCourseFee":4380.00,"totalCommissionItem":{"amount":941.01,"subItemVoList":[{"subItemName":"转换奖励","amount":600.00}]},"totalPerformance":0.00,"coachSubsidyItem":{"amount":6481.07,"subItemVoList":[{"subItemName":"按照店长职级计算工资","amount":6481.07}]},"coachRewardPunishmentItem":{"amount":-200.00,"subItemVoList":[{"subItemName":"顾客【杨贺然】总结少一次","amount":-50.0},{"subItemName":"何栋鑫-张应秋子会员-PQ选项未勾选","amount":-50.0},{"subItemName":"第二次复查：何栋鑫-张应秋子会员-PQ选项未勾选","amount":-50.0},{"subItemName":"顾客【周建华】反馈任务过期，第一次课总结未发规划纸","amount":-50.0}]},"payable":17370.93,"socialSecurityHousingFund":-636.30,"personalIncomeTax":-1413.90},"time":1736312872}
        //sendRequest result:{"code":200,"msg":"操作成功","data":{"reality":15320.73,"baseSalary8":5768.85,"assess15":9551.88,"basePayableSalary":5768.85,"baseSalaryAlgo":"计算=综合底薪(6500.00)*实际出勤天数(11.50)/应出勤天数(26.00)+综合底薪(6000.00)*实际出勤天数(12.00)/应出勤天数(26.00)+综合底薪(2400.00)*实际出勤天数(2.00)/应出勤天数(26.00)+病假工资(0.00)-考勤扣款(60.00)","totalCourseFee":4380.00,"totalCommissionItem":{"amount":941.01,"subItemVoList":[{"subItemName":"转换奖励","amount":600.00},{"subItemName":"新卡提成","amount":341.01}]},"totalPerformance":0.00,"coachSubsidyItem":{"amount":6481.07,"subItemVoList":[{"subItemName":"按照店长职级计算工资","amount":6481.07}]},"coachRewardPunishmentItem":{"amount":-200.00,"subItemVoList":[{"subItemName":"顾客【杨贺然】总结少一次","amount":-50.0},{"subItemName":"何栋鑫-张应秋子会员-PQ选项未勾选","amount":-50.0},{"subItemName":"第二次复查：何栋鑫-张应秋子会员-PQ选项未勾选","amount":-50.0},{"subItemName":"顾客【周建华】反馈任务过期，第一次课总结未发规划纸","amount":-50.0}]},"payable":17370.93,"socialSecurityHousingFund":-636.30,"personalIncomeTax":-1413.90},"time":1736312892}
        //sendRequest result:{"code":200,"msg":"操作成功","data":{"reality":15320.73,"baseSalary8":5768.85,"assess15":9551.88,"basePayableSalary":5768.85,"baseSalaryAlgo":"计算=综合底薪(6500.00)*实际出勤天数(11.50)/应出勤天数(26.00)+综合底薪(6000.00)*实际出勤天数(12.00)/应出勤天数(26.00)+综合底薪(2400.00)*实际出勤天数(2.00)/应出勤天数(26.00)+病假工资(0.00)-考勤扣款(60.00)","totalCourseFee":4380.00,"totalCommissionItem":{"amount":941.01,"subItemVoList":[{"subItemName":"转换奖励","amount":600.00},{"subItemName":"新卡提成","amount":341.01}]},"totalPerformance":0.00,"coachSubsidyItem":{"amount":6481.07,"subItemVoList":[{"subItemName":"按照店长职级计算工资","amount":6481.07}]},"coachRewardPunishmentItem":{"amount":-200.00,"subItemVoList":[{"subItemName":"顾客【杨贺然】总结少一次","amount":-50.0},{"subItemName":"何栋鑫-张应秋子会员-PQ选项未勾选","amount":-50.0},{"subItemName":"第二次复查：何栋鑫-张应秋子会员-PQ选项未勾选","amount":-50.0},{"subItemName":"顾客【周建华】反馈任务过期，第一次课总结未发规划纸","amount":-50.0}]},"payable":17370.93,"socialSecurityHousingFund":-636.30,"personalIncomeTax":-1413.90},"time":1736313062}
        String sign = MD5.create().digestHex(body +"#5601291336c76762f1d56ce5b45b2419");
        JSONObject header = new JSONObject();
        header.set("X-SIGN",sign);
        header.set("X-TRACEID", UUID.randomUUID());
        header.set("X-APPKEY", "10067615200");
        JSONObject result = HttpUtils.sendPost("https://wedata.gymcity.com.cn/openapi/finance/salary/getCoachSalaryDetail", header, body);
        return result;
    }
    /**
     * 查询教练工资列表
     * @return
     */
    private static JSONObject test_queryCoachSalaryList(){
        JSONObject body = new JSONObject();
        body.set("coachId", 14292);
        body.set("salarySummaryId", 30746);

        String sign = MD5.create().digestHex(body +"#5601291336c76762f1d56ce5b45b2419");
        JSONObject header = new JSONObject();
        header.set("X-SIGN",sign);
        header.set("X-TRACEID", UUID.randomUUID());
        header.set("X-APPKEY", "10067615200");
        JSONObject result = HttpUtils.sendPost("https://twedata.gymcity.com.cn/openapi/finance/salary/getCoachSalaryDetail", header, body);
        return result;
    }

}
